# 添加日程
# @Time    : 2025/1/22 上午11:49
# @Author  : lh
# @Email   : lhhlhh822@peatlmail.com
# @File    :
# err_look_schedule_page.py
# @Software: PyCharm
from pages.base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select


# 添加日程页面
class NewSchedulePage(BasePage):
    url = '/crm/index.php?m=event&a=add'
    zt_locator = (By.ID, 'subject')  # 主题
    fzr_locator = (By.ID, 'owner_name')  # 负责人
    start_time_locator = (By.ID, 'start_date')  # 开始时间
    end_time_locator = (By.ID, 'end_date')  # 结束时间
    place_locator = (By.ID, 'venue')  # 地点
    #邮箱
    email_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tbody > tr:nth-child(4) > td:nth-child(4) > input[type=radio]:nth-child(2)')
    choice_xlk_locator = (By.CSS_SELECTOR, '#select1')  # 选择相关，下拉框
    choice_srk_locator = (By.ID, 'module_name')  # 选择相关，输入框
    # 描述
    ms_locator = (By.CSS_SELECTOR,
                  'body > div.container > div.row > div > form > table > tbody > tr:nth-child(6) > td:nth-child(2) > '
                  'textarea')
    save_locator = (By.CSS_SELECTOR,
                    'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(1)')
    # 保存
    result_locator = (By.XPATH, '/html/body/div[5]/div[2]')

    # 操作
    #输入主题内容
    def input_zt(self, zt):
        self.find_element(self.zt_locator).send_keys(zt)  # 主题

    #清空负责人在输入负责人
    def input_fzr(self, fzr):
        self.find_element(self.fzr_locator).clear()
        self.find_element(self.fzr_locator).send_keys(fzr)

    #输入开始时间
    def input_start_time(self, stime):
        self.find_element(self.start_time_locator).send_keys(stime)

    #输入结束时间
    def input_end_time(self, etime):
        self.find_element(self.end_time_locator).send_keys(etime)

    #输入地点内容
    def input_place(self, place):
        self.find_element(self.place_locator).send_keys(place)

    #邮箱
    def click_email(self):
        self.find_element(self.email_locator).click()

    #选择相关下拉框
    def drop_choice_xlk(self, xlk):
        xz = Select(self.find_element(self.choice_xlk_locator))
        xz.select_by_index(xlk)

    #选择相关的输入框
    def input_choice_srk(self, srk):
        self.find_element(self.choice_srk_locator).send_keys(srk)

    #描述输入框输入内容
    def input_ms(self, ms):
        self.find_element(self.ms_locator).send_keys(ms)

    #点击保存按钮
    def click_save(self):
        self.find_element(self.save_locator).click()


#返回增删改查后的提示信息
    def get_result_tips(self):
        return self.find_element(self.result_locator).text